var arrcredit = ['', '信用记录良好', '少量逾期', '征信较差'];
var arrhouse = ['', '无房产', '商品住房', '商铺', '写字楼', '厂房', '宅基地', '其他'];
var arrworklife = ['','一年以下', '1-3年', '3-5年', '5年以上'];
var arrcompanyType = ['', '政府或事业单位', '国企央企', '外资企业', '上市公司', '普通企业', '其他'];
var arrmarry = ['', '未婚', '已婚', '离异', '丧偶'];
var arrdegree = ['', '大专以下', '大专', '本科', '研究生及其以上'];
var arrcar = ['', '无车产', '有车产有抵押', '有车产无抵押'];
var pickerButton = document.getElementsByClassName("xfpicker");
var edu_degree = ""; //文化程度
var company_type = ""; //公司类型
var identity = 2; //用户身份
var real_name = ""; //用户姓名
var user_idnum = ""; //身份证号码
var marry = ""; //婚姻状况
var urgent_name = ""; //紧急联系人姓名
var urgent_tel = ""; //紧急联系人手机号
var credit_status = ""; //信用状况
var tel_time = ""; //手机号使用时间
var Istel_time = ""; //手机号使用时间
var credit_card = ""; //是否有信用卡
var Iscredit_card = ""; //是否有信用卡
var income = ""; //收入
var working_life = ""; //工作年限
var social_security = ""; //连续6个月以上缴纳社保
var Issocial_security = ""; //连续6个月以上缴纳社保
var housing_fund = ""; //连续6个月缴纳公积金
var Ishousing_fund = ""; //连续6个月缴纳公积金
var house_property = ""; //名下房产
var car_property = ""; //名下车产
var admission_time = ""; //入学时间
var school_name = ""; //学校名称
var loan_record = ""; //是否有贷款记录
var Isloan_record = ""; //是否有贷款记录
var stock = ""; //所持股份
var company_name = ""; //公司名称
var tb_account = ""; //是否有淘宝账号
var Istb_account = ""; //是否有淘宝账号
var real_name = ""; //真实姓名
var user_idnum = ""; //身份证号码
var numperson1 = 1;
var numperson2 = 1;
var numperson3 = 1;
var numperson4 = 0;

function isIdCard(cardid) {
	//身份证正则表达式(18位)
	var isIdCard2 = /^[1-9]\d{5}(19\d{2}|[2-9]\d{3})((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])(\d{4}|\d{3}X)$/i;
	var stard = "10X98765432"; //最后一位身份证的号码
	var first = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; //1-17系数
	var sum = 0;
	if(!isIdCard2.test(cardid)) {
		mui.toast('请输入有效的身份证号')
		return;
	}
	var year = cardid.substr(6, 4);
	var month = cardid.substr(10, 2);
	var day = cardid.substr(12, 2);
	var birthday = cardid.substr(6, 8);
	if(birthday != dateToString(new Date(year + '/' + month + '/' + day))) { //校验日期是否合法
		return false;
	}
	for(var i = 0; i < cardid.length - 1; i++) {
		sum += cardid[i] * first[i];
	}
	var result = sum % 11;
	var last = stard[result]; //计算出来的最后一位身份证号码
	if(cardid[cardid.length - 1].toUpperCase() == last) {
		return true;
	} else {
		mui.toast('请输入有效的身份证号')
		return;
	}
}

//console.log(user_idnum);
(function($, window, document, undefined) {
	$.ready(function() {
		var degree = new $.PopPicker(); //文化程度
		var ismarry = new $.PopPicker(); //婚姻状况
		var companyType = new $.PopPicker(); //公司类型
		var workLife = new $.PopPicker(); //工作年限
		var TelTime = new $.PopPicker(); //手机号使用时间
		var House = new $.PopPicker(); //名下房产
		var Credit = new $.PopPicker(); //信用情况
		var edustarttime = new $.PopPicker(); //入学时间
		var Car = new $.PopPicker(); //车产

		//	贷款金额
		degree.setData([{
			value: 1,
			text: '大专以下'
		}, {
			value: 2,
			text: '大专'
		}, {
			value: 3,
			text: '本科'
		}, {
			value: 4,
			text: '研究生及其以上'
		}]);
		pickevent('work_people_Education', degree, edu_degree, "edu_degree");
		pickevent('work_people_companyType', companyType, company_type, "company_type");
		pickevent('work_people_marry', ismarry, marry, "marry");
		pickevent('work_people_workLife', workLife, working_life, "working_life");
		pickistrue('work_people_TelTime', TelTime, tel_time, "tel_time", Istel_time);
		pickistrue('work_people_social_security', TelTime, social_security, "social_security", Issocial_security);
		pickistrue('work_people_credit_card', TelTime, credit_card, "credit_card", Iscredit_card);
		pickistrue('work_people_housing_fund', TelTime, housing_fund, "housing_fund", Ishousing_fund);
		pickistrue('work_people_tb_account', TelTime, tb_account, "tb_account", Istb_account);
		pickistrue('work_people_loan_record', TelTime, loan_record, "loan_record", Isloan_record);
		pickevent('work_people_house_property', House, house_property, "house_property");
		pickevent('work_people_credit_status', Credit, credit_status, "credit_status");
		//企业主
		pickevent('Business_owners_Education', degree, edu_degree, "edu_degree");
		pickistrue('Business_owners_credit_card', TelTime, credit_card, "credit_card", Iscredit_card);
		pickevent('Business_owners_house_property', House, house_property, "house_property");
		pickistrue('Business_owners_TelTime', TelTime, tel_time, "tel_time", Istel_time);
		pickevent('Business_owners_car_property', Car, car_property, "car_property");
		pickistrue('Business_owners_loan_record', TelTime, loan_record, "loan_record", Isloan_record);
		pickevent('Business_owners_credit_status', Credit, credit_status, "credit_status");
		//学生
		pickevent('stu_Education', degree, edu_degree, "edu_degree");
		pickevent('stu_admission_time', edustarttime, admission_time, "admission_time");
		pickistrue('stu_TelTime', TelTime, tel_time, "tel_time", Istel_time);
		pickistrue('stu_credit_card', TelTime, credit_card, "credit_card", Iscredit_card);
		pickistrue('stu_tb_account', TelTime, tb_account, "tb_account", Istb_account);
		pickistrue('stu_loan_record', TelTime, loan_record, "loan_record", Isloan_record);
		pickevent('stu_credit_status', Credit, credit_status, "credit_status");
		ismarry.setData([{
			value: 2,
			text: '已婚'
		}, {
			value: 1,
			text: '未婚'
		}, {
			value: 3,
			text: '离异'
		}, {
			value: 4,
			text: '丧偶'
		}]);
		companyType.setData([{
			value: 1,
			text: '政府或事业单位'
		}, {
			value: 2,
			text: '国企央企'
		}, {
			value: 3,
			text: '外资企业'
		}, {
			value: 4,
			text: '上市公司'
		}, {
			value: 5,
			text: '普通企业'
		}, {
			value: 6,
			text: '其他'
		}]);
		workLife.setData([{
			value: '1',
			text: '一年以下'
		}, {
			value: '2',
			text: '1-3年'
		}, {
			value: '3',
			text: '3-5年'
		}, {
			value: '4',
			text: '5年以上'
		}]);
		TelTime.setData([{
			value: 1,
			text: '是'
		}, {
			value: 0,
			text: '否'
		}]);
		House.setData([{
			value: 1,
			text: '无房产'
		}, {
			value: 2,
			text: '商品住房'
		}, {
			value: 3,
			text: '商铺'
		}, {
			value: 4,
			text: '写字楼'
		}, {
			value: 5,
			text: '厂房'
		}, {
			value: 6,
			text: '宅基地'
		}, {
			value: 7,
			text: '其他'
		}]);
		Credit.setData([{
			value: 1,
			text: '信用记录良好'
		}, {
			value: 2,
			text: '少量逾期'
		}, {
			value: 3,
			text: '征信较差'
		}]);
		Car.setData([{
			value: 1,
			text: '无车产'
		}, {
			value: 2,
			text: '有车产有抵押'
		}, {
			value: 3,
			text: '有车产无抵押'
		}]);
		edustarttime.setData([{
			value: '2010-9-1',
			text: '2010-9-1'
		}, {
			value: '2011-9-1',
			text: '2011-9-1'
		}, {
			value: '2012-9-1',
			text: '2012-9-1'
		}, {
			value: '2013-9-1',
			text: '2013-9-1'
		}, {
			value: '2014-9-1',
			text: '2014-9-1'
		}, {
			value: '2015-9-1',
			text: '2015-9-1'
		}, {
			value: '2016-9-1',
			text: '2016-9-1'
		}]);

		function pickevent(mm, nn, cc, dd) {
			document.getElementById(mm).addEventListener('tap', function(event) {
				nn.show(function(items) {
					document.getElementById(mm).innerText = items[0].text;
					cc = items[0].value;
					document.getElementById(mm).style.color = 'black';
					localStorage.setItem(dd, cc);
					console.log(localStorage.getItem(dd))
						//返回 false 可以阻止选择框的关闭
						//return false;
				});
			}, false);
		};

		function pickistrue(mm, nn, cc, dd, ff) {
			document.getElementById(mm).addEventListener('tap', function(event) {
				nn.show(function(items) {
					document.getElementById(mm).innerText = items[0].text;
					ff = items[0].value;
					cc = items[0].text;
					//			price = cc.innerText;
					document.getElementById(mm).style.color = 'black';
					localStorage.setItem(dd, ff);
					console.log(localStorage.getItem(dd));
						//返回 false 可以阻止选择框的关闭
						//return false;
				});
			}, false);
		};
	});
})(window.mui || window, window, document, undefined);
var direction = document.getElementsByClassName("direction");
var OccupationImg = document.getElementsByClassName("OccupationImg");
var personIdentity = document.getElementsByClassName("person_Identity");
var arrTopImg = ['../../image/my/img_worker@2x.png', '../../image/my/img_boss@2x.png', '../../image/my/img_stu@2x.png']
var numImg = 0;

function setinnerhtml(mm, id, arr, nym) {
	if( localStorage.getItem(mm)!==undefined  && localStorage.getItem(mm) !== null) {
		
		
		if(nym == 1) {
			numperson1++;
		} else if(nym == 2) {
			numperson2++;
		} else if(nym == 3) {
			numperson3++;
		} else {
			numperson4++;
		}
			
		if(localStorage.getItem(mm)!=='100'){
			document.getElementById(id).innerHTML = arr[localStorage.getItem(mm)];
		    console.log(arr[localStorage.getItem(mm)]);
		    console.log(localStorage.getItem(mm));
		}
	}
}

function setinnerhtml1(mm, cc, nym) {
	if( undefined!==localStorage.getItem(mm)  && localStorage.getItem(mm) !== null) {
		document.getElementById(cc).innerHTML = localStorage.getItem(mm);
		if(nym == 1) {
			numperson1++;
		} else if(nym == 2) {
			numperson2++;
		} else if(nym == 3) {
			numperson3++;
		} else {
			numperson4++;
		}
	}
}

function setvalue(mm, cc, nym) {
	if(localStorage.getItem(mm) !== undefined && localStorage.getItem(mm) !== null) {
		document.getElementById(cc).value = localStorage.getItem(mm);
		//		console.log(localStorage.getItem(mm));
		if(nym == 1) {
			numperson1++;
		} else if(nym == 2) {
			numperson2++;
		} else if(nym == 3) {
			numperson3++;
		} else {
			numperson4++;
		}
	}
}

function setistrue(mm, id, nym) { //aa存入名称cc变量名

	//				console.log(localStorage.getItem(aa));
	if(localStorage.getItem(mm) == '1') {
		document.getElementById(id).innerHTML = "是";
		if(nym == 1) {
			numperson1++;
		} else if(nym == 2) {
			numperson2++;
		} else if(nym == 3) {
			numperson3++;
		} else {
			numperson4++;
		}
	}
	if(localStorage.getItem(mm) == '0') {
		document.getElementById(id).innerHTML = "否";
		if(nym == 1) {
			numperson1++;
		} else if(nym == 2) {
			numperson2++;
		} else if(nym == 3) {
			numperson3++;
		} else {
			numperson4++;
		}
	}
}

function setallinner() {
	numperson = 1;
	//身份证
	setvalue("user_idnum", "work_people_idnum", 2);
	setvalue("user_idnum", "Business_owners_idnum", 3);
	setvalue("user_idnum", "student_idnum", 1);
	//名字
	setvalue("real_name", "work_people_name", 2);
	setvalue("real_name", "Business_owners_realname", 3);
	setvalue("real_name", "student_realname", 1);
	//收入
	setvalue("income", "work_people_income", 2);
	setvalue("income", "Business_owners_income", 3);
	//公司名
	setvalue("company_name", "Business_owners_conpanyname", 3);
	//学校名
	setvalue("school_name", "student_school", 1);
	//文化程度
	setinnerhtml("edu_degree", "work_people_Education", arrdegree, 2); //工薪族
	setinnerhtml("edu_degree", "Business_owners_Education", arrdegree, 3); //企业主
	setinnerhtml("edu_degree", "stu_Education", arrdegree, 1); //学生
	//婚姻状态
	setinnerhtml("marry", "work_people_marry", arrmarry, 2); //工薪族
	//公司类型
	setinnerhtml("company_type", "work_people_companyType", arrcompanyType, 2); //工薪族
	//工作年限
	setinnerhtml("working_life", "work_people_workLife", arrworklife, 2); //工薪族
	//手机号使用6个月及其以上

	setistrue("tel_time", "work_people_TelTime", 2); //工薪族
	setistrue("tel_time", "Business_owners_TelTime", 3); //企业主
	setistrue("tel_time", "stu_TelTime", 1); //学生
	//连续6个月缴纳社保
	setistrue("social_security", "work_people_social_security", 2); //工薪族
	//连续6个月缴纳公积金
	setistrue("housing_fund", "work_people_housing_fund", 2); //工薪族
	//是否有信用卡
	setistrue("credit_card", "work_people_credit_card", 2); //工薪族
	setistrue("credit_card", "Business_owners_credit_card", 3); //企业主
	setistrue("credit_card", "stu_credit_card", 1); //学生
	//是否有淘宝账号
	setistrue("tb_account", "work_people_tb_account", 2); //工薪族
	setistrue("tb_account", "stu_tb_account", 1); //学生
	//是否有贷款成功记录
	setistrue("loan_record", "work_people_loan_record", 2); //工薪族
	setistrue("loan_record", "Business_owners_loan_record", 3); //企业主
	setistrue("loan_record", "stu_loan_record", 1); //学生
	//信用情况
	setinnerhtml("credit_status", "work_people_credit_status", arrcredit, 2); //工薪族
	setinnerhtml("credit_status", "Business_owners_credit_status", arrcredit, 3); //企业主
	setinnerhtml("credit_status", "stu_credit_status", arrcredit, 1); //学生
	//名下房产
	setinnerhtml("house_property", "work_people_house_property", arrhouse, 2); //工薪族
	setinnerhtml("house_property", "Business_owners_house_property", arrhouse, 3); //企业主

	//名下车产
	setinnerhtml("car_property", "Business_owners_car_property", arrcar, 3); //企业主
	//入学时间
	setinnerhtml1("admission_time", "stu_admission_time", 1); //学生
	//紧急联系人姓名
	setvalue("urgent_name", "needPerson_urgent_name", 4);
	//紧急联系人电话
	setvalue("urgent_tel", "needPerson_urgent_phone", 4);
	var mm;
	console.log(numperson1 + ':' + numperson2 + ':' + numperson3);
	if(identity == 1) {
		mm = ((parseInt(numperson4) + parseInt(numperson1)) / 13).toPercent();
		document.getElementsByClassName("personal_percent")[0].innerHTML = mm;
		document.getElementsByClassName("progress_inner")[0].style.width = mm;
		console.log(numperson1);
		numperson1 = 1;
		numperson2 = 1;
		numperson3 = 1;
		numperson4 = 0;
	} else if(identity == 2) {
		mm = ((parseInt(numperson4) + parseInt(numperson2)) / 18).toPercent();
		document.getElementsByClassName("personal_percent")[0].innerHTML = mm;
		document.getElementsByClassName("progress_inner")[0].style.width = mm;
		console.log(numperson2);
		numperson1 = 1;
		numperson2 = 1;
		numperson3 = 1;
		numperson4 = 0;
	} else {
		mm = ((parseInt(numperson4) + parseInt(numperson3)) / 14).toPercent();
		document.getElementsByClassName("personal_percent")[0].innerHTML = mm;
		document.getElementsByClassName("progress_inner")[0].style.width = mm;
		console.log(numperson3);
		numperson1 = 1;
		numperson2 = 1;
		numperson3 = 1;
		numperson4 = 0;
	}
}
$.ajax({
	type: 'get',
	url: httpAdress + '/api/user/getuserinfo',
	data: {
		'userid': localStorage.getItem("userid")
			//		'userid': 49
	},
	contentType: "application/json; charset=utf-8",
	dataType: 'jsonp',
	jsonp: "callback",
	jsonpCallback: "successCallback",
	success: function(data) {
		numperson = 1;
		var mydata = data.data;
		if(mydata.identity == 1) {
			numImg = 2;
			ajaxready();
		} else if(mydata.identity == 2) {
			numImg = 0;
			ajaxready();
		} else if(mydata.identity == 3) {
			numImg = 1;
			ajaxready();
		} else {
			if(localStorage.getItem("numImg")) {
				numImg = localStorage.getItem("numImg");
				ajaxready();
			} else {
				numImg = 0;
				ajaxready();
			}
		}

		function ajaxready() {
			for(var i = 0; i < 3; i++) {
				personIdentity[i].style.display = 'none';
			}
			personIdentity[numImg].style.display = 'block';
			OccupationImg[0].src = arrTopImg[numImg];
		}

		document.getElementById("toright").addEventListener('tap', function() {
			//	alert(1);
			numImg++;
			if(numImg == 3) {
				numImg = 0;
			}
			for(var i = 0; i < 3; i++) {
				personIdentity[i].style.display = 'none';
			}
			personIdentity[numImg].style.display = 'block';
			OccupationImg[0].src = arrTopImg[numImg];
			localStorage.setItem("numImg", numImg);
			getidentity();
			setallinner();
		});
		document.getElementById("toleft").addEventListener('tap', function() {
			//	alert(2);
			numImg--;
			if(numImg == -1) {
				numImg = 2;
			}
			for(var i = 0; i < 3; i++) {
				personIdentity[i].style.display = 'none';
			}
			personIdentity[numImg].style.display = 'block';
			OccupationImg[0].src = arrTopImg[numImg];
			localStorage.setItem("numImg", numImg);
			getidentity();
			setallinner();
		});

		function getidentity() {
			if(localStorage.getItem("numImg") == 0) {
				identity = 2;
			} else if(localStorage.getItem("numImg") == 1) {
				identity = 3;
			} else if(localStorage.getItem("numImg") == 2) {
				identity = 1;
			} else {
				identity = 2;
			}
		}

		console.log(JSON.stringify(data));
		function getmation(aa, cc, id, nym) { //aa存入名称cc变量名
			if(cc == null || cc == "") {
				if(localStorage.getItem(aa) !== null&&localStorage.getItem(aa) !== undefined) {
//					alert(1);
					cc = localStorage.getItem(aa);
					document.getElementById(id).value = cc;
				}
			} else {
				if(cc !== undefined) {
					console.log(cc);
					localStorage.setItem(aa, cc);
					document.getElementById(id).value = cc;
					if(nym == 1) {
						numperson1++;
					} else if(nym == 2) {
						numperson2++;
					} else if(nym == 3) {
						numperson3++;
					} else {
						numperson4++;
					}
				}
			}
		}

		function istrue(aa, cc, id, nym) { //aa存入名称cc变量名
			if(cc == 1) {
				localStorage.setItem(aa, cc);
				document.getElementById(id).innerHTML = "是";
				if(nym == 1) {
					numperson1++;
				} else if(nym == 2) {
					numperson2++;
				} else if(nym == 3) {
					numperson3++;
				} else {
					numperson4++;
				}
			} else if(cc == 0) {
				localStorage.setItem(aa, cc);
				document.getElementById(id).innerHTML = "否";
				if(nym == 1) {
					numperson1++;
				} else if(nym == 2) {
					numperson2++;
				} else if(nym == 3) {
					numperson3++;
				} else {
					numperson4++;
				}
			} else {
				if(localStorage.getItem(aa) == '1') {
					document.getElementById(id).innerHTML = "是";
				}
				if(localStorage.getItem(aa) == '0') {
					document.getElementById(id).innerHTML = "否";
				}
			}
			//			}
		}

		function getpickmation(aa, cc, id, arr, nym) { //aa存入名称cc变量名
			if(cc == null || cc == ""||cc==100) {
				if(localStorage.getItem(aa) !== null&&localStorage.getItem(aa) !== undefined) {
					document.getElementById(id).innerHTML = arr[localStorage.getItem(aa)];
					//					console.log(localStorage.getItem(aa))
				}
			} else {
				if(undefined !== cc) {
					localStorage.setItem(aa, cc);
					document.getElementById(id).innerHTML = arr[cc];
					if(nym == 1) {
						numperson1++;
					} else if(nym == 2) {
						numperson2++;
					} else if(nym == 3) {
						numperson3++;
					} else {
						numperson4++;
					}
				}
			}
		}

		function getpickmation1(aa, cc, id, nym) { //aa存入名称cc变量名
			if(cc == null || cc == ""||cc==100) {
				if(localStorage.getItem(aa) !== null&&localStorage.getItem(aa) !== undefined) {
					document.getElementById(id).innerHTML = cc;
					console.log(localStorage.getItem(aa));

				}
			} else {
				if(cc !== undefined) {
					localStorage.setItem(aa, cc);
					document.getElementById(id).innerHTML = cc;
					if(nym == 1) {
						numperson1++;
					} else if(nym == 2) {
						numperson2++;
					} else if(nym == 3) {
						numperson3++;
					} else {
						numperson4++;
					}
				}
			}
		}
		//身份
		if(mydata.identity == null) {
			if(localStorage.getItem("identity") !== null) {
				identity = localStorage.getItem("identity");

				console.log(localStorage.getItem("identity"))
			}
		} else {
			if(mydata.identity !== undefined) {
				identity = mydata.identity;
			}
		}
		//身份证
		getmation("user_idnum", mydata.user_idnum, "work_people_idnum", 2);
		getmation("user_idnum", mydata.user_idnum, "Business_owners_idnum", 3);
		getmation("user_idnum", mydata.user_idnum, "student_idnum", 1);
		//名字
		getmation("real_name", mydata.real_name, "work_people_name", 2);
		getmation("real_name", mydata.real_name, "Business_owners_realname", 3);
		getmation("real_name", mydata.real_name, "student_realname", 1);
		//收入
		getmation("income", mydata.income, "work_people_income", 2);
		getmation("income", mydata.income, "Business_owners_income", 3);
		//公司名
		getmation("company_name", mydata.company_name, "Business_owners_conpanyname", 3);
		//学校名
		getmation("school_name", mydata.school_name, "student_school", 1);
		//文化程度
		getpickmation("edu_degree", mydata.edu_degree, "work_people_Education", arrdegree, 2); //工薪族
		getpickmation("edu_degree", mydata.edu_degree, "Business_owners_Education", arrdegree, 3); //企业主
		getpickmation("edu_degree", mydata.edu_degree, "stu_Education", arrdegree, 1); //学生
		//婚姻状态
		getpickmation("marry", mydata.marry, "work_people_marry", arrmarry, 2); //工薪族
		//公司类型
		getpickmation("company_type", mydata.company_type, "work_people_companyType", arrcompanyType, 2); //工薪族
		//工作年限
		getpickmation("working_life", mydata.working_life, "work_people_workLife", arrworklife, 2); //工薪族
		//手机号使用6个月及其以上

		istrue("tel_time", mydata.tel_time, "work_people_TelTime", 2); //工薪族
		istrue("tel_time", mydata.tel_time, "Business_owners_TelTime", 3); //企业主
		istrue("tel_time", mydata.tel_time, "stu_TelTime", 1); //学生
		//连续6个月缴纳社保
				istrue("social_security", mydata.social_security, "work_people_social_security", 2); //工薪族
		//连续6个月缴纳公积金
		istrue("housing_fund", mydata.housing_fund, "work_people_housing_fund", 2); //工薪族
		//是否有信用卡
		istrue("credit_card", mydata.credit_card, "work_people_credit_card", 2); //工薪族
		istrue("credit_card", mydata.credit_card, "Business_owners_credit_card", 3); //企业主
		istrue("credit_card", mydata.credit_card, "stu_credit_card", 1); //学生
		//是否有淘宝账号
		istrue("tb_account", mydata.tb_account, "work_people_tb_account", 2); //工薪族
		istrue("tb_account", mydata.tb_account, "stu_tb_account", 1); //学生
		//是否有贷款成功记录
		istrue("loan_record", mydata.loan_record, "work_people_loan_record", 2); //工薪族
		istrue("loan_record", mydata.loan_record, "Business_owners_loan_record", 3); //企业主
		istrue("loan_record", mydata.loan_record, "stu_loan_record", 1); //学生
		//信用情况
		getpickmation("credit_status", mydata.credit_status, "work_people_credit_status", arrcredit, 2); //工薪族
		getpickmation("credit_status", mydata.credit_status, "Business_owners_credit_status", arrcredit, 3); //企业主
		getpickmation("credit_status", mydata.credit_status, "stu_credit_status", arrcredit, 1); //学生
		//名下房产
		getpickmation("house_property", mydata.house_property, "work_people_house_property", arrhouse, 2); //工薪族
		getpickmation("house_property", mydata.house_property, "Business_owners_house_property", arrhouse, 3); //企业主
		//名下车产
		getpickmation("car_property", mydata.car_property, "Business_owners_car_property", arrcar, 3); //企业主
		//入学时间
		getpickmation1("admission_time", mydata.admission_time, "stu_admission_time", 1); //学生
		//紧急联系人姓名
		getmation("urgent_name", mydata.urgent_name, "needPerson_urgent_name", 4);
		//紧急联系人电话
		getmation("urgent_tel", mydata.urgent_tel, "needPerson_urgent_phone", 4);
		var mm;

		if(identity == 1) {
			mm = ((parseInt(numperson4) + parseInt(numperson1)) / 13).toPercent();
			document.getElementsByClassName("personal_percent")[0].innerHTML = mm;
			document.getElementsByClassName("progress_inner")[0].style.width = mm;
			numperson1 = 1;
			numperson2 = 1;
			numperson3 = 1;
			numperson4 = 0;
			//		     console.log(numImg);
		} else if(identity == 2) {
			mm = ((parseInt(numperson4) + parseInt(numperson2)) / 18).toPercent();
			document.getElementsByClassName("personal_percent")[0].innerHTML = mm;
			document.getElementsByClassName("progress_inner")[0].style.width = mm;
			numperson1 = 1;
			numperson2 = 1;
			numperson3 = 1;
			numperson4 = 0;
			//		      console.log(numImg);
		} else {
			mm = ((parseInt(numperson4) + parseInt(numperson3)) / 14).toPercent();
			document.getElementsByClassName("personal_percent")[0].innerHTML = mm;
			document.getElementsByClassName("progress_inner")[0].style.width = mm;
			numperson1 = 1;
			numperson2 = 1;
			numperson3 = 1;
			numperson4 = 0;
			//		      console.log(numImg);
		}

	},
	error: function() {
		mui.toast('加载失败，刷新一下');
	}
});

function inputchange(ff, cc, mm, istrue) {
	document.getElementById(mm).addEventListener('change', function() {
		cc = document.getElementById(mm).value;
		localStorage.setItem(ff, cc);
		console.log(cc);
		if(istrue == 1) {
			isIdCard(cc);
		} else if(istrue == 2) {
			if(document.getElementById(mm).value !== 0) {
				var check_phone_number = /^1([38]\d|4[57]|5[0-35-9]|7[06-8]|8[89])\d{8}$/;
				if(accountBox.value.length != 11) {
					mui.toast("请输入有效的手机号！");
					return;
				}
				if(!accountBox.value.match(check_phone_number)) {
					mui.toast("请输入有效的手机号！");
					return;
				}
			}

		}
	})
}
//身份证

inputchange("user_idnum", user_idnum, "work_people_idnum", 1);
inputchange("user_idnum", user_idnum, "Business_owners_idnum", 1);
inputchange("user_idnum", user_idnum, "student_idnum", 1);
//名字
inputchange("real_name", real_name, "work_people_name");
inputchange("real_name", real_name, "Business_owners_realname");
inputchange("real_name", real_name, "student_realname");
//收入
inputchange("income", income, "work_people_income");
inputchange("income", income, "Business_owners_income");
//公司名
inputchange("company_name", company_name, "Business_owners_conpanyname");
//学校名
inputchange("school_name", school_name, "student_school");
//紧急联系人姓名
inputchange("urgent_name", urgent_name, "needPerson_urgent_name");
//紧急联系人电话
inputchange("urgent_tel", urgent_tel, "needPerson_urgent_phone", 2);

function post() {
	$.ajax({
		type: 'get',
		url: httpAdress + '/api/user/saveuserinfo',
		data: {
			'userid': localStorage.getItem("userid"),
			//					'userid': 49,
			edu_degree: localStorage.getItem("edu_degree"),
			company_type: localStorage.getItem("company_type"),
			identity: identity,
			real_name: localStorage.getItem("real_name"),
			user_idnum: localStorage.getItem("user_idnum"),
			marry: localStorage.getItem("marry"),
			urgent_name: localStorage.getItem("urgent_name"),
			urgent_tel: localStorage.getItem("urgent_tel"),
			loan_record: localStorage.getItem("loan_record"),
			credit_status: localStorage.getItem("credit_status"),
			tel_time: localStorage.getItem("tel_time"),
			credit_card: localStorage.getItem("credit_card"),
			income: localStorage.getItem("income"),
			// company_type: localStorage.getItem("company_type"),
			working_life: localStorage.getItem("working_life"),
			social_security: localStorage.getItem("social_security"),
			housing_fund: localStorage.getItem("housing_fund"),
			school_name: localStorage.getItem("school_name"),
			admission_time: localStorage.getItem("admission_time"),
			tb_account: localStorage.getItem("tb_account"),
			company_name: localStorage.getItem("company_name"),
			house_property: localStorage.getItem("house_property"),
			car_property: localStorage.getItem("car_property")
		},
		contentType: "application/json; charset=utf-8",
		dataType: 'jsonp',
		jsonp: "callback",
		jsonpCallback: "successCallback",
		success: function(data) {
			//			alert(2);
			console.log(JSON.stringify(data));
			console.log(identity);
			console.log(localStorage.getItem("admission_time"));
			console.log(localStorage.getItem("income"));
			var mydata = data.data;
			if(data.status == 1) {
//				mui.toast("保存成功!");
				document.getElementById("twindow").style.display='block';
//				window.location.href = '';
                setTimeout(function(){
                	window.location.href = '../../HTML/my/personal.html';
                },1000)
			}
		},
		error: function() {
			mui.toast('加载失败，刷新一下');
		}
	});
}
document.getElementById('save').addEventListener('tap', function() {
		post();
});